<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    

    <title>msg-注册</title>
    <meta name="keywords" content="">
    <meta name="description" content="">
    <base href="./">
    <base target="_blank">
    <link href="favicon.ico" rel="shortcut icon"> 
    <link href="assets/css/bootstrap.min.css?v=3.3.5" rel="stylesheet">
    <link href="assets/css/font-awesome.min.css?v=4.4.0" rel="stylesheet">
    <link href="assets/css/animate.min.css" rel="stylesheet">
    <link href="assets/css/style.min.css?v=4.0.0" rel="stylesheet">
    <link href="assets/plugins/iCheck/custom.css" rel="stylesheet">
    

</head>

<body class="gray-bg">
    <div class="wrapper wrapper-content animated fadeInRight">
        <div class="row">
            
            <div class="col-sm-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-content">
                        <form class="form-horizontal m-t" id="commentForm">
                            <div class="form-group">
                                <label class="col-sm-3 control-label">姓名：</label>
                                <div class="col-sm-4">
                                    <input id="name" name="name" minlength="2" type="text" class="form-control" required="" aria-required="true">
                                    <input id="code" name="code" type="hidden" >
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">账号：</label>
                                <div class="col-sm-4">
                                    <input id="account" name="account" minlength="2" type="text" class="form-control" required="" aria-required="true">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">昵称：</label>
                                <div class="col-sm-4">
                                    <input id="nickname" type="text" class="form-control" name="nickname" required="" aria-required="true">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">手机：</label>
                                <div class="col-sm-4">
                                    <input id="mobile" type="text" class="form-control" name="mobile">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">密码：</label>
                                <div class="col-sm-4">
                                    <input id="pwd" type="password" class="form-control" name="pwd">
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-sm-3 control-label">确认密码：</label>
                                <div class="col-sm-4">
                                    <input id="affirmPwd" type="password" class="form-control" name="affirmPwd">
                                </div>
                            </div>

                            <div class="form-group">
                                <div class="col-sm-4 col-sm-offset-3">
                                    <button class="btn btn-primary" type="button" onclick="save()">提交</button>
                                    <button class="btn btn-default" type="button" onclick="closeWin()">关闭</button>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>

        </div>
    </div>
    <script type="text/javascript" src="config.js"></script>
    <script type="text/javascript" src="assets/js/jquery.min.js?v=2.1.4"></script>
    <script type="text/javascript" src="assets/js/bootstrap.min.js?v=3.3.5"></script>
    <script type="text/javascript" src="assets/js/axios.min.js"></script>
    <script type="text/javascript" src="assets/js/formSerialize.js"></script>
    <script type="text/javascript" src="assets/js/md5.js"></script>
    <script type="text/javascript" src="assets/js/common.js"></script>
    <script type="text/javascript" src="assets/plugins/layer/layer_v3.1.1/layer.js"></script>
    <script type="text/javascript" src="assets/plugins/iCheck/icheck.min.js"></script>
    <script>

        // 登录
        function save(){
            var param = {};
        	var formArr = $("#commentForm").serializeArray();  
        	$.each(formArr,function(i, obj){
        		param[obj.name] = obj.value;
            });
            
            if(param.name==""){
                layer.msg("请输入姓名！")
                return false;
            };
            if(param.account==""){
                layer.msg("请输入账号！")
                return false;
            };
            if(param.pwd==""){
                layer.msg("请输入密码！")
                return false;
            };
            if(param.affirmPwd==""){
                layer.msg("请输入确认密码！")
                return false;
            };
            if(param.affirmPwd!=param.pwd){
                layer.msg("两次密码不一致！")
                return false;
            };
            layer.load(0);
            param.password = md5(param.pwd); 
            axios.post('/sysUser/register/api',param)
                .then(function (response) {
                    layer.closeAll('loading');
                    layer.msg(response.msg);
                    if(response.result){
                        setTimeout(function(){
                            closeWin();
                        }, 1000);
                    }
                    
                })

        }

        // 关闭页面
        function closeWin(){
			window.location.href = "login.html";    
        }
        
    </script>
</body>

</html>